﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YJKStairs.CommonUnit;
using YJKStairs.DataInfos;
using YJKStairs.Form.StairsBaseForm;
using YJKStairs.Kit;

namespace YJKStairs.Form
{
	public partial class RectangleAngleStairsForm : EscBaseForm
	{
		public RectangleAngleStairsForm(ExternalCommandData cmdData)
		{
			this.m_Revit = cmdData;
			this.m_StairsDrawingKit = new RectangleAngleStairsKit(this.m_Revit.Application.Application);
			this.m_ComponentTypeManager = new ComponentTypeManager(this.m_Revit.Application.ActiveUIDocument.Document);
			this.m_listAllLevels = new List<Level>(Common.GetSortLevels(this.m_Revit.Application.ActiveUIDocument.Document, double.MinValue, double.MaxValue));
			this.m_listStairsData = new List<double>();
			this.InitializeComponent();
			this.m_MainPreviewer = new Previewer(this, this.pnlPreview.Left, this.pnlPreview.Top, this.pnlPreview.Width, this.pnlPreview.Height, 1u);
			this.pnlPreview.Visible = false;
			base.MouseWheel += this.m_MainPreviewer.MouseWheel;
		}

		public double TopOffset
		{
			get
			{
				return Common.StrToDouble(this.hyTbTopOffset.Text, 0.0);
			}
			set
			{
				this.hyTbTopOffset.Text = value.ToString("f2");
			}
		}

		public double BottomOffset
		{
			get
			{
				return Common.StrToDouble(this.hyTbBottomOffset.Text, 0.0);
			}
			set
			{
				this.hyTbBottomOffset.Text = value.ToString("f2");
			}
		}

		public double StairsLength
		{
			get
			{
				return Convert.ToDouble(this.hyTbStairsLength.Text);
			}
			set
			{
				this.hyTbStairsLength.Text = value.ToString("f2");
			}
		}

		public double StairsWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbStairsWidth.Text);
			}
			set
			{
				this.hyTbStairsWidth.Text = value.ToString("f2");
			}
		}

		public double OneRunWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbOneRunWidth.Text);
			}
			set
			{
				this.hyTbOneRunWidth.Text = value.ToString("f2");
			}
		}

		public double TwoRunWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbTwoRunWidth.Text);
			}
			set
			{
				this.hyTbTwoRunWidth.Text = value.ToString("f2");
			}
		}

		public double ThreeRunWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbThreeRunWidth.Text);
			}
			set
			{
				this.hyTbThreeRunWidth.Text = value.ToString("f2");
			}
		}

		public double FourRunWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbFourRunWidth.Text);
			}
			set
			{
				this.hyTbFourRunWidth.Text = value.ToString("f2");
			}
		}

		public int OneRunTreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudOneRunTreadCount.Value.ToString());
			}
			set
			{
				this.nudOneRunTreadCount.Value = value;
			}
		}

		public int TwoRunTreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudTwoRunTreadCount.Value.ToString());
			}
			set
			{
				this.nudTwoRunTreadCount.Value = value;
			}
		}

		public int ThreeRunTreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudThreeRunTreadCount.Value.ToString());
			}
			set
			{
				this.nudThreeRunTreadCount.Value = value;
			}
		}

		public int FourRunTreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudFourRunTreadCount.Value.ToString());
			}
			set
			{
				this.nudFourRunTreadCount.Value = value;
			}
		}

		public double TreadHeight
		{
			get
			{
				return Convert.ToDouble(this.hyTbTreadHeight.Text);
			}
			set
			{
				this.hyTbTreadHeight.Text = value.ToString("f2");
			}
		}

		public double TreadDepth
		{
			get
			{
				return Convert.ToDouble(this.hyTbTreadDepth.Text);
			}
			set
			{
				this.hyTbTreadDepth.Text = value.ToString("f2");
			}
		}

		public string UsingRange
		{
			get
			{
				return this.comboUsingRange.Text;
			}
		}

		public int RunStructualDepth
		{
			get
			{
				return Common.StrToInt(this.tbRunThickness.Text, 0);
			}
			set
			{
				this.tbRunThickness.Text = value.ToString();
			}
		}

		public int RunRiserThickness
		{
			get
			{
				return Common.StrToInt(this.tbRiserThickness.Text, 0);
			}
			set
			{
				this.tbRiserThickness.Text = value.ToString();
			}
		}

		public int TreadThickness
		{
			get
			{
				return Common.StrToInt(this.tbTreadThickness.Text, 0);
			}
			set
			{
				this.tbTreadThickness.Text = value.ToString();
			}
		}

		public int LandingThickness
		{
			get
			{
				return Common.StrToInt(this.tbLandThickness.Text, 0);
			}
			set
			{
				this.tbLandThickness.Text = value.ToString();
			}
		}

		public double BeamWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbBeamWidth.Text);
			}
			set
			{
				this.hyTbBeamWidth.Text = value.ToString("f2");
			}
		}

		public double BeamHeight
		{
			get
			{
				return Convert.ToDouble(this.hyTbBeamHeight.Text);
			}
			set
			{
				this.hyTbBeamHeight.Text = value.ToString("f2");
			}
		}

		public double RotateAngle
		{
			get
			{
				return Common.StrToDouble(this.hyTbRotateAngle.Text, 0.0) / 180.0 * Math.PI;
			}
			set
			{
				this.hyTbRotateAngle.Text = (value * 180.0 / Math.PI).ToString("f0");
			}
		}

		public XYZ BasePoint
		{
			get
			{
				return this.m_BasePoint;
			}
		}

		public RectangleAngleStairsForm.MeasureType theMeasureType
		{
			get
			{
				return this.m_MeasureType;
			}
		}

		public int RunCount
		{
			get
			{
				return Common.StrToInt(this.cmbRunCount.Text, 0);
			}
		}

		public bool AntiClockWise
		{
			get
			{
				return this.rbAntiClockwiseUp.Checked;
			}
		}

		public int GetRunCount()
		{
			return this.cmbRunCount.SelectedIndex + 2;
		}

		public LineRunData GetOneRunData()
		{
			LineRunData lineRunData = new LineRunData();
			lineRunData.TheStairsType = this.m_ComponentTypeManager.GetStairsType();
			lineRunData.TreadHeight = Common.MMToFeet(this.TreadHeight);
			lineRunData.TreadDepth = Common.MMToFeet(this.TreadDepth);
			if (2 == this.RunCount && this.AntiClockWise)
			{
				lineRunData.TreadCount = this.TwoRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.TwoRunWidth);
			}
			else if (3 == this.RunCount && this.AntiClockWise)
			{
				lineRunData.TreadCount = this.ThreeRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.ThreeRunWidth);
			}
			else if (4 == this.RunCount && this.AntiClockWise)
			{
				lineRunData.TreadCount = this.FourRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.FourRunWidth);
			}
			else
			{
				lineRunData.TreadCount = this.OneRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.OneRunWidth);
			}
			lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
			lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
			lineRunData.BottomElevation = Common.MMToFeet(this.m_dBottomElevation);
			lineRunData.TreadThickness = Common.MMToFeet((double)this.TreadThickness);
			lineRunData.RunStructualDepth = Common.MMToFeet((double)this.RunStructualDepth);
			lineRunData.RiserThickness = Common.MMToFeet((double)this.RunRiserThickness);
			return lineRunData;
		}

		public LineRunData GetTwoRunData()
		{
			LineRunData lineRunData = new LineRunData();
			lineRunData.TheStairsType = this.m_ComponentTypeManager.GetStairsType();
			lineRunData.TreadHeight = Common.MMToFeet(this.TreadHeight);
			lineRunData.TreadDepth = Common.MMToFeet(this.TreadDepth);
			if (2 == this.RunCount && this.AntiClockWise)
			{
				lineRunData.TreadCount = this.OneRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.OneRunWidth);
			}
			else if (4 == this.RunCount && this.AntiClockWise)
			{
				lineRunData.TreadCount = this.ThreeRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.ThreeRunWidth);
			}
			else
			{
				lineRunData.TreadCount = this.TwoRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.TwoRunWidth);
			}
			lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
			lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
			lineRunData.BottomElevation = Common.MMToFeet(this.m_dBottomElevation);
			lineRunData.TreadThickness = Common.MMToFeet((double)this.TreadThickness);
			lineRunData.RunStructualDepth = Common.MMToFeet((double)this.RunStructualDepth);
			lineRunData.RiserThickness = Common.MMToFeet((double)this.RunRiserThickness);
			return lineRunData;
		}

		public LineRunData GetThreeRunData()
		{
			LineRunData lineRunData = new LineRunData();
			lineRunData.TheStairsType = this.m_ComponentTypeManager.GetStairsType();
			lineRunData.TreadHeight = Common.MMToFeet(this.TreadHeight);
			lineRunData.TreadDepth = Common.MMToFeet(this.TreadDepth);
			if (3 == this.RunCount && this.AntiClockWise)
			{
				lineRunData.TreadCount = this.OneRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.OneRunWidth);
			}
			else if (4 == this.RunCount && this.AntiClockWise)
			{
				lineRunData.TreadCount = this.TwoRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.TwoRunWidth);
			}
			else
			{
				lineRunData.TreadCount = this.ThreeRunTreadCount;
				lineRunData.RunWidth = Common.MMToFeet(this.ThreeRunWidth);
			}
			lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
			lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
			lineRunData.BottomElevation = Common.MMToFeet(this.m_dBottomElevation);
			lineRunData.TreadThickness = Common.MMToFeet((double)this.TreadThickness);
			lineRunData.RunStructualDepth = Common.MMToFeet((double)this.RunStructualDepth);
			lineRunData.RiserThickness = Common.MMToFeet((double)this.RunRiserThickness);
			return lineRunData;
		}

		public LineRunData GetFourRunData()
		{
			LineRunData lineRunData = new LineRunData();
			lineRunData.TheStairsType = this.m_ComponentTypeManager.GetStairsType();
			lineRunData.TreadHeight = Common.MMToFeet(this.TreadHeight);
			lineRunData.TreadDepth = Common.MMToFeet(this.TreadDepth);
			if (4 == this.RunCount && this.AntiClockWise)
			{
				lineRunData.RunWidth = Common.MMToFeet(this.OneRunWidth);
				lineRunData.TreadCount = this.OneRunTreadCount;
			}
			else
			{
				lineRunData.RunWidth = Common.MMToFeet(this.FourRunWidth);
				lineRunData.TreadCount = this.FourRunTreadCount;
			}
			lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
			lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
			lineRunData.BottomElevation = Common.MMToFeet(this.m_dBottomElevation);
			lineRunData.TreadThickness = Common.MMToFeet((double)this.TreadThickness);
			lineRunData.RunStructualDepth = Common.MMToFeet((double)this.RunStructualDepth);
			lineRunData.RiserThickness = Common.MMToFeet((double)this.RunRiserThickness);
			return lineRunData;
		}

		public List<BaseRaillingData> GetRailingData()
		{
			List<BaseRaillingData> list = new List<BaseRaillingData>();
			List<string> heightsOfRailingTypeList = this.m_ComponentTypeManager.GetHeightsOfRailingTypeList();
			if (this.chkInnerRailing.Checked)
			{
				list.Add(new BaseRaillingData
				{
					RailingHeight = Common.MMToFeet(Convert.ToDouble(heightsOfRailingTypeList[this.cmbInnerRailingType.SelectedIndex])),
					TheRailingType = this.m_ComponentTypeManager.GetRailingType(this.cmbInnerRailingType.SelectedIndex),
					m_ptStart = new XYZ(Common.MMToFeet(this.OneRunWidth), 0.0, 0.0)
				});
			}
			if (this.chkOutRailing.Checked)
			{
				list.Add(new BaseRaillingData
				{
					RailingHeight = Common.MMToFeet(Convert.ToDouble(heightsOfRailingTypeList[this.cmbOutRailingType.SelectedIndex])),
					TheRailingType = this.m_ComponentTypeManager.GetRailingType(this.cmbOutRailingType.SelectedIndex),
					m_ptStart = XYZ.Zero
				});
			}
			return list;
		}

		public List<BaseSupportData> GetSupportData()
		{
			List<BaseSupportData> list = new List<BaseSupportData>();
			if (this.chkOutSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_OutSide
				});
			}
			if (this.chkMiddleSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_Mid,
					nSurportNum = 3
				});
			}
			if (this.chkInsideSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_Inside
				});
			}
			return list;
		}

		public BaseBeamData GetBeamData()
		{
			return new BaseBeamData
			{
				BeamHeight = Common.MMToFeet(this.BeamHeight),
				BeamWidth = Common.MMToFeet(this.BeamWidth)
			};
		}

		public YJKStairs.DataInfos.FloorType GetFloorType()
		{
			if (this.rbFirstFloor.Checked)
			{
				return YJKStairs.DataInfos.FloorType.FT_Bottom;
			}
			if (this.rbMiddleFloor.Checked)
			{
				return YJKStairs.DataInfos.FloorType.FT_Mid;
			}
			return YJKStairs.DataInfos.FloorType.FT_Top;
		}

		public List<string> GetLandWidth()
		{
			return new List<string>();
		}

		public bool GetUpstairs()
		{
			return this.m_bClockwiseUp;
		}

		public bool GetNoteInfo()
		{
			return this.chkNoteInfo.Checked;
		}

		public bool GetTBMirror()
		{
			return this.chkTBMirror.Checked;
		}

		public bool GetLRMirror()
		{
			return this.chkLRMirror.Checked;
		}

		public int GetInsertPointIndex()
		{
			return this.m_BasePointIndex;
		}

		public bool GetMiddleBeam()
		{
			return this.chkMiddleBeam.Checked;
		}

		public bool GetLandBeam()
		{
			return this.chkLandBeam.Checked;
		}

		public double GetBottomElevation()
		{
			return this.m_BottomLevel.Elevation;
		}

		public double GetLevelValue()
		{
			if (0.0 == this.m_dLevelValue)
			{
				return Common.MMToFeet(this.m_dStairsHeight);
			}
			return Common.MMToFeet(this.m_dLevelValue);
		}

		public double GetTopOffset()
		{
			if (0.0 != this.m_dStairsHeight)
			{
				return this.TopOffset - this.m_dStairsHeight;
			}
			return this.TopOffset;
		}

		protected override void DefWndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg == 1125)
			{
				if (m.WParam.ToInt32() != 1)
				{
					return;
				}
				List<CurveInfo> curves = new List<CurveInfo>();
				List<TextNoteInfo> textNotes = new List<TextNoteInfo>();
				try
				{
					this.GetProfileCurves(ref curves, ref textNotes);
					this.m_MainPreviewer.Curves = curves;
					this.m_MainPreviewer.TextNotes = textNotes;
					return;
				}
				catch (Exception)
				{
					return;
				}
			}
			base.DefWndProc(ref m);
		}

		private void GetProfileCurves(ref List<CurveInfo> curvesInfoList, ref List<TextNoteInfo> textNoteInfoList)
		{
			RectangleAngleStairs rectangleAngleStairs = new RectangleAngleStairs();
			rectangleAngleStairs.m_dStairsLength = Common.MMToFeet(this.StairsLength);
			rectangleAngleStairs.m_dStairsWidth = Common.MMToFeet(this.StairsWidth);
			rectangleAngleStairs.m_listRunData.Add(this.GetOneRunData());
			rectangleAngleStairs.m_listRunData.Add(this.GetTwoRunData());
			if (1 == this.cmbRunCount.SelectedIndex)
			{
				rectangleAngleStairs.m_listRunData.Add(this.GetThreeRunData());
			}
			else if (2 == this.cmbRunCount.SelectedIndex)
			{
				rectangleAngleStairs.m_listRunData.Add(this.GetThreeRunData());
				rectangleAngleStairs.m_listRunData.Add(this.GetFourRunData());
			}
			rectangleAngleStairs.m_nRunCount = this.GetRunCount();
			rectangleAngleStairs.m_BeamData = this.GetBeamData();
			rectangleAngleStairs.m_FloorType = this.GetFloorType();
			this.m_StairsDrawingKit.RectangleAngleStairsProfileCurves(ref rectangleAngleStairs, this.chkNoteInfo.Checked, this.m_BasePointIndex, this.chkLRMirror.Checked, this.chkTBMirror.Checked, this.m_bClockwiseUp, this.RotateAngle, false, this.chkMiddleBeam.Checked, this.chkLandBeam.Checked, false);
			foreach (SingleRunCurveInfo singleRunCurveInfo in rectangleAngleStairs.m_listRunCurve)
			{
				curvesInfoList.AddRange(singleRunCurveInfo.RunBoundaryCurvesInfoList);
				curvesInfoList.AddRange(singleRunCurveInfo.RunRiserCurvesInfoList);
				curvesInfoList.AddRange(singleRunCurveInfo.RunPathCurvesInfoList);
			}
			foreach (LandingCurveInfo landingCurveInfo in rectangleAngleStairs.m_listLandCurve)
			{
				curvesInfoList.AddRange(landingCurveInfo.m_arCurveInfo);
			}
			curvesInfoList.AddRange(rectangleAngleStairs.m_listOtherCurve);
			textNoteInfoList = rectangleAngleStairs.m_listText;
		}

		private void ReadData()
		{
			string path = Product.UserDataLocation + "RectangleAngleStairsForm.dat";
			if (!File.Exists(path))
			{
				this.m_Calculating = true;
				this.comboUsingRange.Text = "其他建筑";
				this.hyTbTopOffset.Text = "0.00";
				this.hyTbBottomOffset.Text = "0.00";
				this.hyTbStairsLength.Text = "4980.00";
				this.hyTbStairsWidth.Text = "4980.00";
				this.hyTbTreadHeight.Text = "166.67";
				this.hyTbTreadDepth.Text = "270.00";
				this.tbRunThickness.Text = "120";
				this.tbLandThickness.Text = "120";
				this.tbRiserThickness.Text = "30";
				this.tbTreadThickness.Text = "30";
				this.nudOneRunTreadCount.Value = 11m;
				this.nudTwoRunTreadCount.Value = 11m;
				this.nudThreeRunTreadCount.Value = 4m;
				this.nudFourRunTreadCount.Value = 4m;
				this.hyTbOneRunWidth.Text = "1200";
				this.hyTbTwoRunWidth.Text = "1200";
				this.hyTbThreeRunWidth.Text = "1200";
				this.hyTbFourRunWidth.Text = "1200";
				this.cmbRunCount.SelectedIndex = 0;
				this.chkSymmetry.Checked = true;
				this.chkInnerRailing.Checked = true;
				this.chkOutRailing.Checked = true;
				this.chkOutSupport.Checked = false;
				this.chkMiddleSupport.Checked = false;
				this.chkInsideSupport.Checked = false;
				this.chkMiddleBeam.Checked = true;
				this.chkLandBeam.Checked = true;
				this.hyTbBeamWidth.Text = "200.00";
				this.hyTbBeamHeight.Text = "400.00";
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = true;
				this.rbTopFloor.Checked = false;
				this.rbClockwiseUp.Checked = true;
				this.rbAntiClockwiseUp.Checked = false;
				this.hyTbRotateAngle.Text = "0.00";
				this.chkTBMirror.Checked = false;
				this.chkLRMirror.Checked = false;
				this.chkNoteInfo.Checked = true;
				this.m_Calculating = false;
				return;
			}
			this.m_Calculating = true;
			FileStream fileStream = new FileStream(path, FileMode.Open);
			StreamReader streamReader = new StreamReader(fileStream);
			streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
			int index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.comboUsingRange, index);
			this.hyTbTopOffset.Text = Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			this.hyTbBottomOffset.Text = Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			this.hyTbStairsLength.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbStairsWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			string text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbTreadHeight.Text = text;
			this.hyTbTreadDepth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.tbRunThickness.Text = Common.StrToInt(streamReader.ReadLine(), 120).ToString();
			this.tbLandThickness.Text = Common.StrToInt(streamReader.ReadLine(), 120).ToString();
			this.tbRiserThickness.Text = Common.StrToInt(streamReader.ReadLine(), 30).ToString();
			this.tbTreadThickness.Text = Common.StrToInt(streamReader.ReadLine(), 30).ToString();
			this.nudOneRunTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.nudTwoRunTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.nudThreeRunTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.nudFourRunTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.hyTbOneRunWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbTwoRunWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbThreeRunWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbFourRunWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbRunCount, index);
			this.chkSymmetry.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkInnerRailing.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkOutRailing.Checked = Convert.ToBoolean(streamReader.ReadLine());
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbInnerRailingType, index);
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbOutRailingType, index);
			this.chkOutSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkMiddleSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkInsideSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbSupport, index);
			this.chkMiddleBeam.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkLandBeam.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.hyTbBeamWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbBeamHeight.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			int num = Convert.ToInt32(streamReader.ReadLine());
			if (num == 0)
			{
				this.rbFirstFloor.Checked = true;
				this.rbMiddleFloor.Checked = false;
				this.rbTopFloor.Checked = false;
			}
			else if (1 == num)
			{
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = true;
				this.rbTopFloor.Checked = false;
			}
			else
			{
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = false;
				this.rbTopFloor.Checked = true;
			}
			if (Convert.ToInt32(streamReader.ReadLine()) == 0)
			{
				this.rbClockwiseUp.Checked = true;
				this.rbAntiClockwiseUp.Checked = false;
			}
			else
			{
				this.rbClockwiseUp.Checked = false;
				this.rbAntiClockwiseUp.Checked = true;
			}
			this.hyTbRotateAngle.Text = Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			this.m_BasePointIndex = Convert.ToInt32(streamReader.ReadLine());
			this.chkTBMirror.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkLRMirror.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkNoteInfo.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.hyTbTreadHeight.Text = text;
			streamReader.Close();
			fileStream.Close();
			this.m_Calculating = false;
		}

		public void SaveData()
		{
			FileStream fileStream = new FileStream(Product.UserDataLocation + "RectangleAngleStairsForm.dat", FileMode.Create);
			StreamWriter streamWriter = new StreamWriter(fileStream);
			streamWriter.WriteLine(this.comboUsingRange.SelectedIndex);
			streamWriter.WriteLine(this.hyTbTopOffset.Text);
			streamWriter.WriteLine(this.hyTbBottomOffset.Text);
			streamWriter.WriteLine(this.hyTbStairsLength.Text);
			streamWriter.WriteLine(this.hyTbStairsWidth.Text);
			streamWriter.WriteLine(this.hyTbTreadHeight.Text);
			streamWriter.WriteLine(this.hyTbTreadDepth.Text);
			streamWriter.WriteLine(this.tbRunThickness.Text);
			streamWriter.WriteLine(this.tbLandThickness.Text);
			streamWriter.WriteLine(this.tbRiserThickness.Text);
			streamWriter.WriteLine(this.tbTreadThickness.Text);
			streamWriter.WriteLine(this.nudOneRunTreadCount.Value.ToString());
			streamWriter.WriteLine(this.nudTwoRunTreadCount.Value.ToString());
			streamWriter.WriteLine(this.nudThreeRunTreadCount.Value.ToString());
			streamWriter.WriteLine(this.nudFourRunTreadCount.Value.ToString());
			streamWriter.WriteLine(this.hyTbOneRunWidth.Text);
			streamWriter.WriteLine(this.hyTbTwoRunWidth.Text);
			streamWriter.WriteLine(this.hyTbThreeRunWidth.Text);
			streamWriter.WriteLine(this.hyTbFourRunWidth.Text);
			streamWriter.WriteLine(this.cmbRunCount.SelectedIndex.ToString());
			streamWriter.WriteLine(this.chkSymmetry.Checked);
			streamWriter.WriteLine(this.chkInnerRailing.Checked);
			streamWriter.WriteLine(this.chkOutRailing.Checked);
			streamWriter.WriteLine(this.cmbInnerRailingType.SelectedIndex);
			streamWriter.WriteLine(this.cmbOutRailingType.SelectedIndex);
			streamWriter.WriteLine(this.chkOutSupport.Checked);
			streamWriter.WriteLine(this.chkMiddleSupport.Checked);
			streamWriter.WriteLine(this.chkInsideSupport.Checked);
			streamWriter.WriteLine(this.cmbSupport.SelectedIndex);
			streamWriter.WriteLine(this.chkMiddleBeam.Checked);
			streamWriter.WriteLine(this.chkLandBeam.Checked);
			streamWriter.WriteLine(this.hyTbBeamWidth.Text);
			streamWriter.WriteLine(this.hyTbBeamHeight.Text);
			if (this.rbFirstFloor.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else if (this.rbMiddleFloor.Checked)
			{
				streamWriter.WriteLine(1);
			}
			else
			{
				streamWriter.WriteLine(2);
			}
			if (this.rbClockwiseUp.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else
			{
				streamWriter.WriteLine(1);
			}
			streamWriter.WriteLine(this.hyTbRotateAngle.Text);
			streamWriter.WriteLine(this.m_BasePointIndex);
			streamWriter.WriteLine(this.chkTBMirror.Checked);
			streamWriter.WriteLine(this.chkLRMirror.Checked);
			streamWriter.WriteLine(this.chkNoteInfo.Checked);
			streamWriter.Flush();
			streamWriter.Close();
			fileStream.Close();
		}

		private void RectangleAngleStairsForm_Load(object sender, EventArgs e)
		{
			base.Icon = Resource.YArchitechIcon;
			this.InitializeComboBox(this.comboUsingRange, this.m_ComponentTypeManager.GetUsingRangeList());
			this.InitializeComboBox(this.cmbInnerRailingType, this.m_ComponentTypeManager.GetRailingTypeNameList());
			this.InitializeComboBox(this.cmbOutRailingType, this.m_ComponentTypeManager.GetRailingTypeNameList());
			this.InitializeComboBox(this.cmbSupport, this.m_ComponentTypeManager.GetSupportTypeNameList());
			List<string> list = new List<string>();
			foreach (Element element in this.m_listAllLevels)
			{
				if (!list.Contains(element.Name))
				{
					list.Add(element.Name);
				}
			}
			this.InitializeComboBox(this.cmbTopLevel, list);
			this.InitializeComboBox(this.cmbBottomLevel, list);
			list.Clear();
			list.Add("2");
			list.Add("3");
			list.Add("4");
			this.InitializeComboBox(this.cmbRunCount, list);
			this.ReadData();
			this.UpdateRailingData();
			this.UpdateSupportData();
			this.UpdateBeamData();
			this.UpdateStairsData();
			if (this.m_nRunCountIndex == 0)
			{
				this.OneRunTreadCount = (int)((this.StairsWidth - this.TwoRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
				this.TwoRunTreadCount = (int)((this.StairsLength - this.OneRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
			}
			else if (1 == this.m_nRunCountIndex)
			{
				this.OneRunTreadCount = (int)((this.StairsWidth - this.TwoRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
				this.TwoRunTreadCount = (int)((this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
				this.ThreeRunTreadCount = this.OneRunTreadCount;
			}
			else
			{
				this.OneRunTreadCount = (int)((this.StairsWidth - this.TwoRunWidth - this.FourRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
				this.TwoRunTreadCount = (int)((this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
				this.ThreeRunTreadCount = this.OneRunTreadCount;
				this.FourRunTreadCount = this.TwoRunTreadCount;
			}
			this.m_nOneRunMax = this.OneRunTreadCount;
			this.m_nTwoRunMax = this.TwoRunTreadCount;
			this.m_BottomLevel = this.m_Revit.Application.ActiveUIDocument.ActiveView.GenLevel;
			for (int i = 0; i < this.m_listAllLevels.Count; i++)
			{
				if (this.m_BottomLevel.Id == this.m_listAllLevels.ElementAt(i).Id)
				{
					if (this.m_listAllLevels.Count - 1 == i)
					{
						this.m_TopLevel = this.m_BottomLevel;
						this.cmbTopLevel.SelectedIndex = i;
						this.m_dLevelValue = Common.FeetToMM(this.m_BottomLevel.Elevation - this.m_listAllLevels.ElementAt(i - 1).Elevation);
						this.TopOffset = this.m_dLevelValue;
					}
					else
					{
						this.m_TopLevel = this.m_listAllLevels.ElementAt(i + 1);
						this.cmbTopLevel.SelectedIndex = i + 1;
						this.m_dLevelValue = Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
						this.TopOffset = 0.0;
					}
					this.cmbBottomLevel.SelectedIndex = i;
					break;
				}
			}
			this.BottomOffset = 0.0;
		}

		private void RectangleAngleStairsForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (DialogResult.Cancel == base.DialogResult)
			{
				return;
			}
			string text = "";
			if (!this.ValidatingParameters(ref text))
			{
				MessageBox.Show(text, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
			}
			this.SaveData();
		}

		private void InitializeComboBox(System.Windows.Forms.ComboBox control, List<string> typeNameList)
		{
			control.Items.Clear();
			foreach (string item in typeNameList)
			{
				control.Items.Add(item);
			}
			if (control.Items.Count > 0)
			{
				control.SelectedIndex = 0;
			}
		}

		private void SetComboBoxSelectedIndex(System.Windows.Forms.ComboBox control, int index)
		{
			if (index < 0 || index >= control.Items.Count)
			{
				return;
			}
			control.SelectedIndex = index;
		}

		private bool ValidatingParameters(ref string message)
		{
			if (this.chkInnerRailing.Checked || this.chkOutRailing.Checked)
			{
				if (this.cmbInnerRailingType.Items.Count == 0)
				{
					message = "栏杆类型为空";
					return false;
				}
				if (this.cmbOutRailingType.Items.Count == 0)
				{
					message = "栏杆类型为空";
					return false;
				}
			}
			if ((this.chkOutSupport.Checked || this.chkMiddleSupport.Checked || this.chkInsideSupport.Checked) && this.cmbSupport.Items.Count == 0)
			{
				message = "支持类型为空";
				return false;
			}
			return true;
		}

		private bool ValidatingDataParam(ref string message)
		{
			List<ValidatingData> list = new List<ValidatingData>();
			ValidatingData item = new ValidatingData
			{
				Type = DataType.DT_RunWidth,
				Name = "一跑宽度",
				Value = this.OneRunWidth
			};
			list.Add(item);
			item.Type = DataType.DT_RunWidth;
			item.Name = "二跑宽度";
			item.Value = this.TwoRunWidth;
			list.Add(item);
			if (3 <= this.GetRunCount())
			{
				item.Type = DataType.DT_RunWidth;
				item.Name = "三跑宽度";
				item.Value = this.ThreeRunWidth;
				list.Add(item);
			}
			if (4 <= this.GetRunCount())
			{
				item.Type = DataType.DT_RunWidth;
				item.Name = "四跑宽度";
				item.Value = this.FourRunWidth;
				list.Add(item);
			}
			item.Type = DataType.DT_TreadHeight;
			item.Name = "踏步高度";
			item.Value = this.TreadHeight;
			list.Add(item);
			item.Type = DataType.DT_TreadDepth;
			item.Name = "踏步宽度";
			item.Value = this.TreadDepth;
			list.Add(item);
			item.Type = DataType.DT_TreadCount;
			item.Name = "一跑步数";
			item.Count = this.OneRunTreadCount;
			list.Add(item);
			item.Type = DataType.DT_TreadCount;
			item.Name = "二跑步数";
			item.Count = this.TwoRunTreadCount;
			list.Add(item);
			if (3 <= this.GetRunCount())
			{
				item.Type = DataType.DT_TreadCount;
				item.Name = "三跑步数";
				item.Count = this.ThreeRunTreadCount;
				list.Add(item);
			}
			if (4 <= this.GetRunCount())
			{
				item.Type = DataType.DT_TreadCount;
				item.Name = "四跑步数";
				item.Count = this.FourRunTreadCount;
				list.Add(item);
			}
			message = FormParamManager.GetValidatingData(list, this.UsingRange, this.StairsWidth);
			return message == null;
		}

		private void ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType changeType)
		{
			if (this.m_Calculating)
			{
				return;
			}
			this.m_Calculating = true;
			try
			{
				double stairsHeight = FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset);
				int num = FormParamManager.GetStairsTreadCount(stairsHeight, this.TreadHeight);
				if (this.m_nRunCountIndex == 0)
				{
					num -= 2;
				}
				else if (1 == this.m_nRunCountIndex)
				{
					num -= 3;
				}
				else
				{
					num -= 4;
				}
				switch (changeType)
				{
				case RectangleAngleStairsForm.ParametersChangeType.PCT_StairsLength:
					if (this.m_nRunCountIndex == 0)
					{
						this.m_nTwoRunMax = (int)((this.StairsLength - this.OneRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
					}
					else
					{
						this.m_nTwoRunMax = (int)((this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
					}
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_StairsWidth:
					if (this.m_nRunCountIndex == 0 || 1 == this.m_nRunCountIndex)
					{
						this.m_nOneRunMax = (int)((this.StairsWidth - this.TwoRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
					}
					else
					{
						this.m_nOneRunMax = (int)((this.StairsWidth - this.TwoRunWidth - this.FourRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
					}
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_TreadHeight:
					this.UpdateTreadCount(num);
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_TreadDepth:
					if (this.m_nRunCountIndex == 0)
					{
						this.StairsLength = (double)this.TwoRunTreadCount * this.TreadDepth + this.OneRunWidth + this.m_dMinLandWidth;
						this.StairsWidth = (double)this.OneRunTreadCount * this.TreadDepth + this.TwoRunWidth + this.m_dMinLandWidth;
					}
					else if (1 == this.m_nRunCountIndex)
					{
						this.StairsLength = (double)this.TwoRunTreadCount * this.TreadDepth + this.OneRunWidth + this.ThreeRunWidth + this.m_dMinLandWidth * 2.0;
						this.StairsWidth = (double)this.OneRunTreadCount * this.TreadDepth + this.TwoRunWidth + this.m_dMinLandWidth;
					}
					else
					{
						this.StairsLength = (double)this.TwoRunTreadCount * this.TreadDepth + this.OneRunWidth + this.ThreeRunWidth + this.m_dMinLandWidth * 2.0;
						this.StairsWidth = (double)this.OneRunTreadCount * this.TreadDepth + this.TwoRunWidth + this.FourRunWidth + this.m_dMinLandWidth * 2.0;
					}
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_OneRunTreadCountAdd:
					if (this.m_nOneRunMax < this.OneRunTreadCount)
					{
						int num2 = this.OneRunTreadCount;
						this.OneRunTreadCount = num2 - 1;
					}
					if (this.chkSymmetry.Checked && (1 == this.m_nRunCountIndex || 2 == this.m_nRunCountIndex))
					{
						this.ThreeRunTreadCount = this.OneRunTreadCount;
					}
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_OneRunTreadCountSub:
					if (3 > this.OneRunTreadCount)
					{
						int num2 = this.OneRunTreadCount;
						this.OneRunTreadCount = num2 + 1;
					}
					if (this.chkSymmetry.Checked && (1 == this.m_nRunCountIndex || 2 == this.m_nRunCountIndex))
					{
						this.ThreeRunTreadCount = this.OneRunTreadCount;
					}
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_TwoRunTreadCountAdd:
					if (this.m_nTwoRunMax < this.TwoRunTreadCount)
					{
						int num2 = this.TwoRunTreadCount;
						this.TwoRunTreadCount = num2 - 1;
					}
					if (this.chkSymmetry.Checked && 2 == this.m_nRunCountIndex)
					{
						this.FourRunTreadCount = this.TwoRunTreadCount;
					}
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_TwoRunTreadCountSub:
					if (3 > this.TwoRunTreadCount)
					{
						int num2 = this.TwoRunTreadCount;
						this.TwoRunTreadCount = num2 + 1;
					}
					if (this.chkSymmetry.Checked && 2 == this.m_nRunCountIndex)
					{
						this.FourRunTreadCount = this.TwoRunTreadCount;
					}
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_ThreeRunTreadCountAdd:
					if (this.m_nOneRunMax < this.ThreeRunTreadCount)
					{
						int num2 = this.ThreeRunTreadCount;
						this.ThreeRunTreadCount = num2 - 1;
					}
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_ThreeRunTreadCountSub:
					if (3 > this.ThreeRunTreadCount)
					{
						int num2 = this.ThreeRunTreadCount;
						this.ThreeRunTreadCount = num2 + 1;
					}
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_FourRunTreadCountAdd:
					if (this.m_nTwoRunMax < this.FourRunTreadCount)
					{
						int num2 = this.FourRunTreadCount;
						this.FourRunTreadCount = num2 - 1;
					}
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				case RectangleAngleStairsForm.ParametersChangeType.PCT_FourRunTreadCountSub:
					if (3 > this.FourRunTreadCount)
					{
						int num2 = this.FourRunTreadCount;
						this.FourRunTreadCount = num2 + 1;
					}
					this.TreadHeight = this.UpdateTreadHeight(stairsHeight);
					break;
				}
				this.m_Calculating = false;
			}
			catch (Exception)
			{
				this.m_Calculating = false;
			}
		}

		private RectangleAngleStairsForm.ValveChangeType isAddNumericUpDown(NumericUpDown ctrl)
		{
			int num = Convert.ToInt32(ctrl.Text);
			int num2 = Convert.ToInt32(ctrl.Value.ToString());
			if (num2 == num)
			{
				return RectangleAngleStairsForm.ValveChangeType.VCT_None;
			}
			if (num2 == num + 1)
			{
				return RectangleAngleStairsForm.ValveChangeType.VCT_AddOne;
			}
			if (num2 + 1 == num)
			{
				return RectangleAngleStairsForm.ValveChangeType.VCT_SubtractOne;
			}
			return RectangleAngleStairsForm.ValveChangeType.VCT_ValveChanged;
		}

		private void UpdateRailingData()
		{
			if (!this.chkInnerRailing.Checked)
			{
				this.cmbInnerRailingType.Enabled = false;
			}
			else
			{
				this.cmbInnerRailingType.Enabled = true;
			}
			if (!this.chkOutRailing.Checked)
			{
				this.cmbOutRailingType.Enabled = false;
				return;
			}
			this.cmbOutRailingType.Enabled = true;
		}

		private void UpdateSupportData()
		{
			if (!this.chkOutSupport.Checked && !this.chkInsideSupport.Checked)
			{
				this.cmbSupport.Enabled = false;
				return;
			}
			this.cmbSupport.Enabled = true;
		}

		private void UpdateBeamData()
		{
			if (!this.chkMiddleBeam.Checked && !this.chkLandBeam.Checked)
			{
				this.hyTbBeamWidth.Enabled = false;
				this.hyTbBeamHeight.Enabled = false;
				return;
			}
			this.hyTbBeamWidth.Enabled = true;
			this.hyTbBeamHeight.Enabled = true;
		}

		private void UpdateStairsData()
		{
			this.m_listStairsData.Clear();
			this.m_listStairsData.Add(this.StairsLength);
			this.m_listStairsData.Add(this.StairsWidth);
			this.m_listStairsData.Add(this.TreadHeight);
			this.m_listStairsData.Add(this.TreadDepth);
			this.m_listStairsData.Add(this.BeamWidth);
			this.m_listStairsData.Add(this.BeamHeight);
			this.m_listStairsData.Add(this.RotateAngle);
			this.m_listStairsData.Add(this.OneRunWidth);
			this.m_listStairsData.Add(this.TwoRunWidth);
			this.m_listStairsData.Add(this.ThreeRunWidth);
			this.m_listStairsData.Add(this.FourRunWidth);
		}

		private void UpdateRunDisplayInfo()
		{
			if (this.chkSymmetry.Checked)
			{
				if (1 == this.m_nRunCountIndex)
				{
					this.nudThreeRunTreadCount.Value = this.nudOneRunTreadCount.Value;
					this.nudThreeRunTreadCount.Enabled = false;
					this.hyTbThreeRunWidth.Text = this.hyTbOneRunWidth.Text;
					this.btnThreeRunWidth.Enabled = false;
					this.hyTbThreeRunWidth.Enabled = false;
					return;
				}
				if (2 == this.m_nRunCountIndex)
				{
					this.nudThreeRunTreadCount.Value = this.nudOneRunTreadCount.Value;
					this.nudThreeRunTreadCount.Enabled = false;
					this.hyTbThreeRunWidth.Text = this.hyTbOneRunWidth.Text;
					this.btnThreeRunWidth.Enabled = false;
					this.hyTbThreeRunWidth.Enabled = false;
					this.nudFourRunTreadCount.Value = this.nudTwoRunTreadCount.Value;
					this.nudFourRunTreadCount.Enabled = false;
					this.hyTbFourRunWidth.Text = this.hyTbTwoRunWidth.Text;
					this.btnFourRunWidth.Enabled = false;
					this.hyTbFourRunWidth.Enabled = false;
					return;
				}
			}
			else
			{
				if (1 == this.m_nRunCountIndex)
				{
					this.nudThreeRunTreadCount.Enabled = true;
					this.btnThreeRunWidth.Enabled = true;
					this.hyTbThreeRunWidth.Enabled = true;
					return;
				}
				if (2 == this.m_nRunCountIndex)
				{
					this.nudThreeRunTreadCount.Enabled = true;
					this.btnThreeRunWidth.Enabled = true;
					this.hyTbThreeRunWidth.Enabled = true;
					this.nudFourRunTreadCount.Enabled = true;
					this.btnFourRunWidth.Enabled = true;
					this.hyTbFourRunWidth.Enabled = true;
				}
			}
		}

		private void UpdateMaxTreadCount()
		{
			if (this.m_nRunCountIndex == 0)
			{
				this.m_nOneRunMax = (int)((this.StairsWidth - this.TwoRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
				this.m_nTwoRunMax = (int)((this.StairsLength - this.OneRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
				return;
			}
			if (1 == this.m_nRunCountIndex)
			{
				this.m_nOneRunMax = (int)((this.StairsWidth - this.TwoRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
				this.m_nTwoRunMax = (int)((this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
				return;
			}
			this.m_nOneRunMax = (int)((this.StairsWidth - this.TwoRunWidth - this.FourRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
			this.m_nTwoRunMax = (int)((this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
		}

		private void UpdateTreadCount(int nTreadCount)
		{
			if (this.m_nRunCountIndex == 0)
			{
				if (this.m_nOneRunMax + this.m_nTwoRunMax <= nTreadCount)
				{
					this.OneRunTreadCount = this.m_nOneRunMax;
					this.TwoRunTreadCount = this.m_nTwoRunMax;
					return;
				}
				int num = nTreadCount / 2;
				if (num <= this.m_nOneRunMax)
				{
					this.OneRunTreadCount = num;
				}
				else
				{
					this.OneRunTreadCount = this.m_nOneRunMax;
				}
				if (num <= this.m_nTwoRunMax)
				{
					this.TwoRunTreadCount = num;
				}
				else
				{
					this.TwoRunTreadCount = this.m_nTwoRunMax;
				}
				while (this.OneRunTreadCount + this.TwoRunTreadCount < nTreadCount)
				{
					if (this.OneRunTreadCount < this.m_nOneRunMax)
					{
						int num2 = this.OneRunTreadCount;
						this.OneRunTreadCount = num2 + 1;
					}
					else
					{
						if (this.TwoRunTreadCount >= this.m_nTwoRunMax)
						{
							return;
						}
						int num2 = this.TwoRunTreadCount;
						this.TwoRunTreadCount = num2 + 1;
					}
				}
				return;
			}
			else if (1 == this.m_nRunCountIndex)
			{
				if (this.m_nOneRunMax * 2 + this.m_nTwoRunMax <= nTreadCount)
				{
					this.OneRunTreadCount = this.m_nOneRunMax;
					this.TwoRunTreadCount = this.m_nTwoRunMax;
					this.ThreeRunTreadCount = this.m_nOneRunMax;
					return;
				}
				int num = nTreadCount / 3;
				if (num <= this.m_nOneRunMax)
				{
					this.OneRunTreadCount = num;
					this.ThreeRunTreadCount = num;
				}
				else
				{
					this.OneRunTreadCount = this.m_nOneRunMax;
					this.ThreeRunTreadCount = this.m_nOneRunMax;
				}
				if (num <= this.m_nTwoRunMax)
				{
					this.TwoRunTreadCount = num;
				}
				else
				{
					this.TwoRunTreadCount = this.m_nTwoRunMax;
				}
				while (this.OneRunTreadCount * 2 + this.TwoRunTreadCount < nTreadCount)
				{
					if (this.OneRunTreadCount < this.m_nOneRunMax)
					{
						if (this.OneRunTreadCount * 2 + this.TwoRunTreadCount + 2 > nTreadCount)
						{
							return;
						}
						int num2 = this.OneRunTreadCount;
						this.OneRunTreadCount = num2 + 1;
						num2 = this.ThreeRunTreadCount;
						this.ThreeRunTreadCount = num2 + 1;
					}
					else
					{
						if (this.TwoRunTreadCount >= this.m_nTwoRunMax)
						{
							return;
						}
						int num2 = this.TwoRunTreadCount;
						this.TwoRunTreadCount = num2 + 1;
					}
				}
				return;
			}
			else
			{
				if (this.m_nOneRunMax * 2 + this.m_nTwoRunMax * 2 <= nTreadCount)
				{
					this.OneRunTreadCount = this.m_nOneRunMax;
					this.TwoRunTreadCount = this.m_nTwoRunMax;
					this.ThreeRunTreadCount = this.m_nOneRunMax;
					this.FourRunTreadCount = this.m_nTwoRunMax;
				}
				else
				{
					int num = nTreadCount / 4;
					if (num <= this.m_nOneRunMax)
					{
						this.OneRunTreadCount = num;
						this.ThreeRunTreadCount = num;
					}
					else
					{
						this.OneRunTreadCount = this.m_nOneRunMax;
						this.ThreeRunTreadCount = this.m_nOneRunMax;
					}
					if (num <= this.m_nTwoRunMax)
					{
						this.TwoRunTreadCount = num;
						this.FourRunTreadCount = num;
					}
					else
					{
						this.TwoRunTreadCount = this.m_nTwoRunMax;
						this.FourRunTreadCount = this.m_nTwoRunMax;
					}
				}
				while (this.OneRunTreadCount * 2 + this.TwoRunTreadCount * 2 < nTreadCount)
				{
					if (this.OneRunTreadCount < this.m_nOneRunMax)
					{
						if (this.OneRunTreadCount * 2 + this.TwoRunTreadCount * 2 + 2 > nTreadCount)
						{
							break;
						}
						int num2 = this.OneRunTreadCount;
						this.OneRunTreadCount = num2 + 1;
						num2 = this.ThreeRunTreadCount;
						this.ThreeRunTreadCount = num2 + 1;
					}
					else
					{
						if (this.TwoRunTreadCount >= this.m_nTwoRunMax || this.OneRunTreadCount * 2 + this.TwoRunTreadCount * 2 + 2 > nTreadCount)
						{
							break;
						}
						int num2 = this.TwoRunTreadCount;
						this.TwoRunTreadCount = num2 + 1;
						num2 = this.FourRunTreadCount;
						this.FourRunTreadCount = num2 + 1;
					}
				}
			}
		}

		private void CalcCmpTreadCount()
		{
			int num = FormParamManager.GetStairsTreadCount(FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset), this.TreadHeight);
			if (this.m_nRunCountIndex == 0)
			{
				num -= 2;
			}
			else if (1 == this.m_nRunCountIndex)
			{
				num -= 3;
			}
			else
			{
				num -= 4;
			}
			if (this.m_nRunCountIndex == 0)
			{
				if (this.m_nOneRunMax + this.m_nTwoRunMax <= num)
				{
					this.m_nOneCmpTreandCount = this.m_nOneRunMax;
					this.m_nTwoCmpTreandCount = this.m_nTwoRunMax;
					return;
				}
				int num2 = num / 2;
				if (num2 <= this.m_nOneRunMax)
				{
					this.m_nOneCmpTreandCount = num2;
				}
				else
				{
					this.m_nOneCmpTreandCount = this.m_nOneRunMax;
				}
				if (num2 <= this.m_nTwoRunMax)
				{
					this.m_nTwoCmpTreandCount = num2;
				}
				else
				{
					this.m_nTwoCmpTreandCount = this.m_nTwoRunMax;
				}
				while (this.m_nOneCmpTreandCount + this.m_nTwoCmpTreandCount < num)
				{
					if (this.m_nOneCmpTreandCount < this.m_nOneRunMax)
					{
						this.m_nOneCmpTreandCount++;
					}
					else
					{
						if (this.m_nTwoCmpTreandCount >= this.m_nTwoRunMax)
						{
							return;
						}
						this.m_nTwoCmpTreandCount++;
					}
				}
				return;
			}
			else if (1 == this.m_nRunCountIndex)
			{
				if (this.m_nOneRunMax * 2 + this.m_nTwoRunMax <= num)
				{
					this.m_nOneCmpTreandCount = this.m_nOneRunMax;
					this.m_nTwoCmpTreandCount = this.m_nTwoRunMax;
					this.m_nThreeCmpTreandCount = this.m_nOneRunMax;
					return;
				}
				int num2 = num / 3;
				if (num2 <= this.m_nOneRunMax)
				{
					this.m_nOneCmpTreandCount = num2;
					this.m_nThreeCmpTreandCount = num2;
				}
				else
				{
					this.m_nOneCmpTreandCount = this.m_nOneRunMax;
					this.m_nThreeCmpTreandCount = this.m_nOneRunMax;
				}
				if (num2 <= this.m_nTwoRunMax)
				{
					this.m_nTwoCmpTreandCount = num2;
				}
				else
				{
					this.m_nTwoCmpTreandCount = this.m_nTwoRunMax;
				}
				while (this.m_nOneCmpTreandCount * 2 + this.m_nTwoCmpTreandCount < num)
				{
					if (this.m_nOneCmpTreandCount < this.m_nOneRunMax)
					{
						if (this.m_nOneCmpTreandCount * 2 + this.m_nTwoCmpTreandCount + 2 > num)
						{
							return;
						}
						this.m_nOneCmpTreandCount++;
						this.m_nThreeCmpTreandCount++;
					}
					else
					{
						if (this.m_nTwoCmpTreandCount >= this.m_nTwoRunMax)
						{
							return;
						}
						this.m_nTwoCmpTreandCount++;
					}
				}
				return;
			}
			else
			{
				if (this.m_nOneRunMax * 2 + this.m_nTwoRunMax * 2 <= num)
				{
					this.m_nOneCmpTreandCount = this.m_nOneRunMax;
					this.m_nTwoCmpTreandCount = this.m_nTwoRunMax;
					this.m_nThreeCmpTreandCount = this.m_nOneRunMax;
					this.m_nFourCmpTreandCount = this.m_nTwoRunMax;
				}
				else
				{
					int num2 = num / 4;
					if (num2 <= this.m_nOneRunMax)
					{
						this.m_nOneCmpTreandCount = num2;
						this.m_nThreeCmpTreandCount = num2;
					}
					else
					{
						this.m_nOneCmpTreandCount = this.m_nOneRunMax;
						this.m_nThreeCmpTreandCount = this.m_nOneRunMax;
					}
					if (num2 <= this.m_nTwoRunMax)
					{
						this.m_nTwoCmpTreandCount = num2;
						this.m_nFourCmpTreandCount = num2;
					}
					else
					{
						this.m_nTwoCmpTreandCount = this.m_nTwoRunMax;
						this.m_nFourCmpTreandCount = this.m_nTwoRunMax;
					}
				}
				while (this.m_nOneCmpTreandCount * 2 + this.m_nTwoCmpTreandCount * 2 < num)
				{
					if (this.m_nOneCmpTreandCount < this.m_nOneRunMax)
					{
						if (this.m_nOneCmpTreandCount * 2 + this.m_nTwoCmpTreandCount * 2 + 2 > num)
						{
							break;
						}
						this.m_nOneCmpTreandCount++;
						this.m_nThreeCmpTreandCount++;
					}
					else
					{
						if (this.m_nTwoCmpTreandCount >= this.m_nTwoRunMax || this.m_nOneCmpTreandCount * 2 + this.m_nTwoCmpTreandCount * 2 + 2 > num)
						{
							break;
						}
						this.m_nTwoCmpTreandCount++;
						this.m_nFourCmpTreandCount++;
					}
				}
			}
		}

		private bool IsNotValidRunMinTread()
		{
			bool result = false;
			this.CalcCmpTreadCount();
			if (this.m_nOneCmpTreandCount < FormParamManager.m_nRunMinTreadCount || this.m_nTwoCmpTreandCount < FormParamManager.m_nRunMinTreadCount || this.m_nThreeCmpTreandCount < FormParamManager.m_nRunMinTreadCount || this.m_nFourCmpTreandCount < FormParamManager.m_nRunMinTreadCount)
			{
				result = true;
			}
			return result;
		}

		private double UpdateTreadHeight(double dStairsHeight)
		{
			double result;
			if (this.m_nRunCountIndex == 0)
			{
				result = dStairsHeight / (double)(this.OneRunTreadCount + this.TwoRunTreadCount + 2);
			}
			else if (1 == this.m_nRunCountIndex)
			{
				result = dStairsHeight / (double)(this.OneRunTreadCount + this.TwoRunTreadCount + this.ThreeRunTreadCount + 3);
			}
			else
			{
				result = dStairsHeight / (double)(this.OneRunTreadCount + this.TwoRunTreadCount + this.ThreeRunTreadCount + this.FourRunTreadCount + 4);
			}
			return result;
		}

		private bool UpdateRunWidth(int nRunIndex)
		{
			bool result = true;
			switch (nRunIndex)
			{
			case 1:
				if (this.m_nRunCountIndex == 0)
				{
					if (1E-09 < this.OneRunWidth + this.TreadDepth * 2.0 + this.m_dMinLandWidth - this.StairsLength)
					{
						result = false;
					}
					else
					{
						this.TwoRunTreadCount = (int)((this.StairsLength - this.OneRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
					}
				}
				else if (this.chkSymmetry.Checked)
				{
					if (1E-09 < this.OneRunWidth * 2.0 + this.TreadDepth * 2.0 + this.m_dMinLandWidth * 2.0 - this.StairsLength)
					{
						result = false;
					}
					else
					{
						this.TwoRunTreadCount = (int)((this.StairsLength - this.OneRunWidth * 2.0 - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
						if (2 == this.m_nRunCountIndex)
						{
							this.FourRunTreadCount = this.TwoRunTreadCount;
						}
					}
				}
				else if (1E-09 < this.OneRunWidth + this.ThreeRunWidth + this.TreadDepth * 2.0 + this.m_dMinLandWidth * 2.0 - this.StairsLength)
				{
					result = false;
				}
				else
				{
					this.TwoRunTreadCount = (int)((this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
					if (2 == this.m_nRunCountIndex)
					{
						this.FourRunTreadCount = this.TwoRunTreadCount;
					}
				}
				break;
			case 2:
				if (this.m_nRunCountIndex == 0 || 1 == this.m_nRunCountIndex)
				{
					if (1E-09 < this.TwoRunWidth + this.TreadDepth * 2.0 + this.m_dMinLandWidth - this.StairsWidth)
					{
						result = false;
					}
					else
					{
						this.OneRunTreadCount = (int)((this.StairsWidth - this.TwoRunWidth - this.m_dMinLandWidth) / this.TreadDepth);
						if (1 == this.m_nRunCountIndex)
						{
							this.ThreeRunTreadCount = this.OneRunTreadCount;
						}
					}
				}
				else if (this.chkSymmetry.Checked)
				{
					if (1E-09 < this.TwoRunWidth * 2.0 + this.TreadDepth * 2.0 + this.m_dMinLandWidth * 2.0 - this.StairsWidth)
					{
						result = false;
					}
					else
					{
						this.OneRunTreadCount = (int)((this.StairsWidth - this.TwoRunWidth * 2.0 - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
						this.ThreeRunTreadCount = this.OneRunTreadCount;
					}
				}
				else if (1E-09 < this.TwoRunWidth + this.FourRunWidth + this.TreadDepth * 2.0 + this.m_dMinLandWidth * 2.0 - this.StairsWidth)
				{
					result = false;
				}
				else
				{
					this.OneRunTreadCount = (int)((this.StairsWidth - this.TwoRunWidth - this.FourRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
					this.ThreeRunTreadCount = this.OneRunTreadCount;
				}
				break;
			case 3:
				if (1E-09 < this.OneRunWidth + this.ThreeRunWidth + this.TreadDepth * 2.0 + this.m_dMinLandWidth * 2.0 - this.StairsLength)
				{
					result = false;
				}
				else
				{
					this.TwoRunTreadCount = (int)((this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
					if (2 == this.m_nRunCountIndex)
					{
						this.FourRunTreadCount = this.TwoRunTreadCount;
					}
				}
				break;
			case 4:
				if (1E-09 < this.TwoRunWidth + this.FourRunWidth + this.TreadDepth * 2.0 + this.m_dMinLandWidth * 2.0 - this.StairsWidth)
				{
					result = false;
				}
				else
				{
					this.OneRunTreadCount = (int)((this.StairsWidth - this.TwoRunWidth - this.FourRunWidth - this.m_dMinLandWidth * 2.0) / this.TreadDepth);
					this.ThreeRunTreadCount = this.OneRunTreadCount;
				}
				break;
			}
			return result;
		}

		private void chkSymmetry_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateRunDisplayInfo();
			this.m_MainPreviewer.Refresh();
		}

		private void chkInnerRailing_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateRailingData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkOutRailing_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateRailingData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkOutSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkMiddleSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkInnerSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkMiddleBeam_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateBeamData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkLandBeam_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateBeamData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkTBMirror_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkLRMirror_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkNoteInfo_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbClockwiseUp_CheckedChanged(object sender, EventArgs e)
		{
			this.m_bClockwiseUp = true;
			this.m_MainPreviewer.Refresh();
		}

		private void rbAntiClockwiseUp_CheckedChanged(object sender, EventArgs e)
		{
			this.m_bClockwiseUp = false;
			this.m_MainPreviewer.Refresh();
		}

		private void rbFirstFloor_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbMiddleFloor_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbTopFloor_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTopOffset_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBottomOffset_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbStairsLength_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_StairsLength);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbStairsWidth_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_StairsWidth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTreadHeight_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTreadDepth_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_TreadDepth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBeamWidth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBeamHeight_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbRotateAngle_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void cmbTopLevel_TextChanged(object sender, EventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex && this.cmbTopLevel.SelectedIndex == 0)
			{
				return;
			}
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
		}

		private void cmbBottomLevel_TextChanged(object sender, EventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
		}

		private void hyTbTopOffset_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTopOffset.Text)
			{
				return;
			}
			this.hyTbTopOffset.Text = Common.StrToDouble(this.hyTbTopOffset.Text, 0.0).ToString("f2");
			if (this.m_TopLevel.Id == this.m_BottomLevel.Id && this.TopOffset <= this.BottomOffset)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbTopOffset.Focus();
				return;
			}
			if (this.IsNotValidRunMinTread())
			{
				MessageBox.Show(FormParamManager.m_strRunMinTreadChkTip, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbTopOffset.Focus();
				return;
			}
		}

		private void hyTbBottomOffset_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBottomOffset.Text)
			{
				return;
			}
			this.hyTbBottomOffset.Text = Common.StrToDouble(this.hyTbBottomOffset.Text, 0.0).ToString("f2");
			if (this.m_TopLevel.Id == this.m_BottomLevel.Id && this.TopOffset <= this.BottomOffset)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbBottomOffset.Focus();
				return;
			}
			if (this.IsNotValidRunMinTread())
			{
				MessageBox.Show(FormParamManager.m_strRunMinTreadChkTip, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbBottomOffset.Focus();
				return;
			}
		}

		private void hyTbStairsLength_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbStairsLength.Text)
			{
				return;
			}
			this.hyTbStairsLength.Text = Convert.ToDouble(this.hyTbStairsLength.Text).ToString("f2");
			double num;
			if (this.m_nRunCountIndex == 0)
			{
				num = this.StairsLength - this.OneRunWidth - (double)this.TwoRunTreadCount * this.TreadDepth - this.m_dMinLandWidth;
			}
			else if (1 == this.m_nRunCountIndex)
			{
				num = this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - (double)this.TwoRunTreadCount * this.TreadDepth - this.m_dMinLandWidth * 2.0;
			}
			else
			{
				double num2 = this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - (double)this.TwoRunTreadCount * this.TreadDepth - this.m_dMinLandWidth * 2.0;
				double num3 = this.StairsLength - this.OneRunWidth - this.ThreeRunWidth - (double)this.FourRunTreadCount * this.TreadDepth - this.m_dMinLandWidth * 2.0;
				num = ((num2 < num3) ? num2 : num3);
			}
			double num4 = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbStairsLength.Text, ValidatingType.GreaterThanZero, ref num4) || !ValueValidatingKit.ValidatingDouble(num.ToString(), ValidatingType.GreaterThanAndEqualZero, ref num4))
			{
				MessageBox.Show("梯间长度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.StairsLength = this.m_listStairsData.ElementAt(0);
				return;
			}
			this.UpdateStairsData();
			this.UpdateMaxTreadCount();
		}

		private void hyTbStairsWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbStairsWidth.Text)
			{
				return;
			}
			this.hyTbStairsWidth.Text = Convert.ToDouble(this.hyTbStairsWidth.Text).ToString("f2");
			double num = 0.0;
			if (this.m_nRunCountIndex == 0)
			{
				num = this.StairsWidth - this.TwoRunWidth - (double)this.OneRunTreadCount * this.TreadDepth - this.m_dMinLandWidth;
			}
			else if (1 == this.m_nRunCountIndex)
			{
				double num2 = this.StairsWidth - this.TwoRunWidth - (double)this.OneRunTreadCount * this.TreadDepth - this.m_dMinLandWidth;
				double num3 = this.StairsWidth - this.TwoRunWidth - (double)this.ThreeRunTreadCount * this.TreadDepth - this.m_dMinLandWidth;
				num = ((num2 < num3) ? num2 : num3);
			}
			else if (2 == this.m_nRunCountIndex)
			{
				double num4 = this.StairsWidth - this.TwoRunWidth - this.FourRunWidth - (double)this.OneRunTreadCount * this.TreadDepth - this.m_dMinLandWidth * 2.0;
				double num5 = this.StairsWidth - this.TwoRunWidth - this.FourRunWidth - (double)this.ThreeRunTreadCount * this.TreadDepth - this.m_dMinLandWidth * 2.0;
				num = ((num4 < num5) ? num4 : num5);
			}
			double num6 = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbStairsWidth.Text, ValidatingType.GreaterThanZero, ref num6) || !ValueValidatingKit.ValidatingDouble(num.ToString(), ValidatingType.GreaterThanAndEqualZero, ref num6))
			{
				MessageBox.Show("梯间宽度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.StairsWidth = this.m_listStairsData.ElementAt(1);
				return;
			}
			this.UpdateStairsData();
			this.UpdateMaxTreadCount();
		}

		private void hyTbTreadHeight_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTreadHeight.Text)
			{
				return;
			}
			this.hyTbTreadHeight.Text = Convert.ToDouble(this.hyTbTreadHeight.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTreadHeight.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("踏步高度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TreadHeight = this.m_listStairsData.ElementAt(2);
				return;
			}
			if (this.IsNotValidRunMinTread())
			{
				MessageBox.Show(FormParamManager.m_strRunMinTreadChkTip, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TreadHeight = this.m_listStairsData.ElementAt(2);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbTreadDepth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTreadDepth.Text)
			{
				return;
			}
			this.hyTbTreadDepth.Text = Convert.ToDouble(this.hyTbTreadDepth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTreadDepth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("踏步宽度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TreadDepth = this.m_listStairsData.ElementAt(3);
				return;
			}
			this.UpdateStairsData();
			this.UpdateMaxTreadCount();
		}

		private void hyTbBeamWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBeamWidth.Text)
			{
				return;
			}
			this.hyTbBeamWidth.Text = Convert.ToDouble(this.hyTbBeamWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbBeamWidth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯梁宽度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.BeamWidth = this.m_listStairsData.ElementAt(4);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbBeamHeight_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBeamHeight.Text)
			{
				return;
			}
			this.hyTbBeamHeight.Text = Convert.ToDouble(this.hyTbBeamHeight.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbBeamHeight.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯梁高度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.BeamHeight = this.m_listStairsData.ElementAt(5);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbRotateAngle_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbRotateAngle.Text)
			{
				return;
			}
			this.hyTbRotateAngle.Text = Common.StrToDouble(this.hyTbRotateAngle.Text, 0.0).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbRotateAngle.Text, ValidatingType.Minus2PITo2PI, ref num))
			{
				MessageBox.Show("旋转角度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.RotateAngle = this.m_listStairsData.ElementAt(6);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbOneRunWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbOneRunWidth.Text)
			{
				return;
			}
			this.hyTbOneRunWidth.Text = Convert.ToDouble(this.hyTbOneRunWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbOneRunWidth.Text, ValidatingType.GreaterThanZero, ref num) || !this.UpdateRunWidth(1))
			{
				MessageBox.Show("一跑宽度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.OneRunWidth = this.m_listStairsData.ElementAt(7);
				return;
			}
			if (this.chkSymmetry.Checked && (1 == this.m_nRunCountIndex || 2 == this.m_nRunCountIndex))
			{
				this.ThreeRunWidth = this.OneRunWidth;
			}
			this.TreadHeight = this.UpdateTreadHeight(FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset));
			this.UpdateStairsData();
			this.UpdateMaxTreadCount();
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTwoRunWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTwoRunWidth.Text)
			{
				return;
			}
			this.hyTbTwoRunWidth.Text = Convert.ToDouble(this.hyTbTwoRunWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTwoRunWidth.Text, ValidatingType.GreaterThanZero, ref num) || !this.UpdateRunWidth(2))
			{
				MessageBox.Show("二跑宽度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TwoRunWidth = this.m_listStairsData.ElementAt(8);
				return;
			}
			if (this.chkSymmetry.Checked && 2 == this.m_nRunCountIndex)
			{
				this.FourRunWidth = this.TwoRunWidth;
			}
			this.TreadHeight = this.UpdateTreadHeight(FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset));
			this.UpdateStairsData();
			this.UpdateMaxTreadCount();
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbThreeRunWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbThreeRunWidth.Text)
			{
				return;
			}
			this.hyTbThreeRunWidth.Text = Convert.ToDouble(this.hyTbThreeRunWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbThreeRunWidth.Text, ValidatingType.GreaterThanZero, ref num) || !this.UpdateRunWidth(3))
			{
				MessageBox.Show("三跑宽度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.ThreeRunWidth = this.m_listStairsData.ElementAt(9);
				return;
			}
			this.TreadHeight = this.UpdateTreadHeight(FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset));
			this.UpdateStairsData();
			this.UpdateMaxTreadCount();
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbFourRunWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbFourRunWidth.Text)
			{
				return;
			}
			this.hyTbFourRunWidth.Text = Convert.ToDouble(this.hyTbFourRunWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbFourRunWidth.Text, ValidatingType.GreaterThanZero, ref num) || !this.UpdateRunWidth(4))
			{
				MessageBox.Show("四跑宽度参数不正确.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.FourRunWidth = this.m_listStairsData.ElementAt(10);
				return;
			}
			this.TreadHeight = this.UpdateTreadHeight(FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset));
			this.UpdateStairsData();
			this.UpdateMaxTreadCount();
			this.m_MainPreviewer.Refresh();
		}

		private void cmbTopLevel_Validating(object sender, CancelEventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶部低于楼梯底部.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
		}

		private void cmbBottomLevel_Validating(object sender, CancelEventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶部低于楼梯底部.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
		}

		private void btnStairsLength_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = RectangleAngleStairsForm.MeasureType.MT_StairsLength;
			this.hyTbStairsLength.Focus();
		}

		private void btnStairsWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = RectangleAngleStairsForm.MeasureType.MT_StairsWidth;
			this.hyTbStairsWidth.Focus();
		}

		private void btnRotateAngle_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = RectangleAngleStairsForm.MeasureType.MT_Angle;
		}

		private void btnOneRunWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = RectangleAngleStairsForm.MeasureType.MT_OneRunWidth;
			this.hyTbOneRunWidth.Focus();
		}

		private void btnTwoRunWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = RectangleAngleStairsForm.MeasureType.MT_TwoRunWidth;
			this.hyTbTwoRunWidth.Focus();
		}

		private void btnThreeRunWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = RectangleAngleStairsForm.MeasureType.MT_ThreeRunWidth;
			this.hyTbThreeRunWidth.Focus();
		}

		private void btnFourRunWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = RectangleAngleStairsForm.MeasureType.MT_FourRunWidth;
			this.hyTbFourRunWidth.Focus();
		}

		private void btnChangeInsertPoint_Click(object sender, EventArgs e)
		{
			int num = this.m_BasePointIndex + 1;
			if (this.cmbRunCount.SelectedIndex == 0 || 2 == this.cmbRunCount.SelectedIndex)
			{
				this.m_BasePointIndex = num % 3;
			}
			else
			{
				this.m_BasePointIndex = num % 4;
			}
			this.m_MainPreviewer.Refresh();
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (StairsFormManager.IsInvalidFormInput(this))
			{
				return;
			}
			this.m_MeasureType = RectangleAngleStairsForm.MeasureType.MT_None;
			string text = "";
			if (!this.ValidatingDataParam(ref text))
			{
				DialogResult dialogResult = MessageBox.Show(text, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
				if (DialogResult.Cancel == dialogResult)
				{
					return;
				}
				if (DialogResult.OK == dialogResult)
				{
					base.DialogResult = DialogResult.OK;
					base.Close();
				}
			}
			base.DialogResult = DialogResult.OK;
		}

		private void nudOneRunTreadCount_ValueChanged(object sender, EventArgs e)
		{
			RectangleAngleStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudOneRunTreadCount);
			if (valveChangeType == RectangleAngleStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (RectangleAngleStairsForm.ValveChangeType.VCT_AddOne == valveChangeType)
			{
				this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_OneRunTreadCountAdd);
			}
			else if (RectangleAngleStairsForm.ValveChangeType.VCT_SubtractOne == valveChangeType)
			{
				this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_OneRunTreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nudTwoRunTreadCount_ValueChanged(object sender, EventArgs e)
		{
			RectangleAngleStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudTwoRunTreadCount);
			if (valveChangeType == RectangleAngleStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (RectangleAngleStairsForm.ValveChangeType.VCT_AddOne == valveChangeType)
			{
				this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_TwoRunTreadCountAdd);
			}
			else if (RectangleAngleStairsForm.ValveChangeType.VCT_SubtractOne == valveChangeType)
			{
				this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_TwoRunTreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nudThreeRunTreadCount_ValueChanged(object sender, EventArgs e)
		{
			RectangleAngleStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudThreeRunTreadCount);
			if (valveChangeType == RectangleAngleStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (RectangleAngleStairsForm.ValveChangeType.VCT_AddOne == valveChangeType)
			{
				this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_ThreeRunTreadCountAdd);
			}
			else if (RectangleAngleStairsForm.ValveChangeType.VCT_SubtractOne == valveChangeType)
			{
				this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_ThreeRunTreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nudFourRunTreadCount_ValueChanged(object sender, EventArgs e)
		{
			RectangleAngleStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudFourRunTreadCount);
			if (valveChangeType == RectangleAngleStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (RectangleAngleStairsForm.ValveChangeType.VCT_AddOne == valveChangeType)
			{
				this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_FourRunTreadCountAdd);
			}
			else if (RectangleAngleStairsForm.ValveChangeType.VCT_SubtractOne == valveChangeType)
			{
				this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_FourRunTreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void cmbRunCount_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.m_nRunCountIndex = this.cmbRunCount.SelectedIndex;
			if ("" != this.hyTbStairsLength.Text || "" != this.hyTbStairsWidth.Text)
			{
				if (1 == this.m_nRunCountIndex)
				{
					if (1E-09 < this.OneRunWidth * 2.0 + 2.0 * this.TreadDepth + this.m_dMinLandWidth * 2.0 - this.StairsLength)
					{
						this.StairsLength = this.OneRunWidth * 2.0 + (double)this.TwoRunTreadCount * this.TreadDepth + this.m_dMinLandWidth * 2.0;
					}
					else
					{
						while (this.TwoRunTreadCount >= 2 && 1E-09 < this.OneRunWidth * 2.0 + (double)this.TwoRunTreadCount * this.TreadDepth + this.m_dMinLandWidth * 2.0 - this.StairsLength)
						{
							int num = this.TwoRunTreadCount;
							this.TwoRunTreadCount = num - 1;
						}
					}
					this.ThreeRunWidth = this.OneRunWidth;
				}
				else if (2 == this.m_nRunCountIndex)
				{
					if (1E-09 < this.OneRunWidth * 2.0 + 2.0 * this.TreadDepth + this.m_dMinLandWidth * 2.0 - this.StairsLength)
					{
						this.StairsLength = this.OneRunWidth * 2.0 + (double)this.TwoRunTreadCount * this.TreadDepth + this.m_dMinLandWidth * 2.0;
					}
					else
					{
						while (this.TwoRunTreadCount >= 2 && 1E-09 < this.OneRunWidth * 2.0 + (double)this.TwoRunTreadCount * this.TreadDepth + this.m_dMinLandWidth * 2.0 - this.StairsLength)
						{
							int num = this.TwoRunTreadCount;
							this.TwoRunTreadCount = num - 1;
						}
					}
					if (1E-09 < this.TwoRunWidth * 2.0 + 2.0 * this.TreadDepth + this.m_dMinLandWidth * 2.0 - this.StairsWidth)
					{
						this.StairsWidth = this.TwoRunWidth * 2.0 + (double)this.OneRunTreadCount * this.TreadDepth + this.m_dMinLandWidth * 2.0;
					}
					else
					{
						while (this.OneRunTreadCount >= 2 && 1E-09 < this.TwoRunWidth * 2.0 + (double)this.OneRunTreadCount * this.TreadDepth + this.m_dMinLandWidth * 2.0 - this.StairsWidth)
						{
							int num = this.OneRunTreadCount;
							this.OneRunTreadCount = num - 1;
						}
					}
					this.ThreeRunWidth = this.OneRunWidth;
					this.FourRunWidth = this.TwoRunWidth;
				}
				this.TreadHeight = this.UpdateTreadHeight(FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset));
				this.UpdateMaxTreadCount();
			}
			if (this.m_nRunCountIndex == 0)
			{
				this.nudThreeRunTreadCount.Enabled = false;
				this.btnThreeRunWidth.Enabled = false;
				this.hyTbThreeRunWidth.Enabled = false;
				this.nudFourRunTreadCount.Enabled = false;
				this.btnFourRunWidth.Enabled = false;
				this.hyTbFourRunWidth.Enabled = false;
				this.chkSymmetry.Enabled = false;
			}
			else if (1 == this.m_nRunCountIndex)
			{
				this.nudThreeRunTreadCount.Enabled = true;
				this.btnThreeRunWidth.Enabled = true;
				this.hyTbThreeRunWidth.Enabled = true;
				this.nudFourRunTreadCount.Enabled = false;
				this.btnFourRunWidth.Enabled = false;
				this.hyTbFourRunWidth.Enabled = false;
				this.chkSymmetry.Enabled = true;
			}
			else
			{
				this.nudThreeRunTreadCount.Enabled = true;
				this.btnThreeRunWidth.Enabled = true;
				this.hyTbThreeRunWidth.Enabled = true;
				this.nudFourRunTreadCount.Enabled = true;
				this.btnFourRunWidth.Enabled = true;
				this.hyTbFourRunWidth.Enabled = true;
				this.chkSymmetry.Enabled = true;
			}
			this.chkSymmetry.Checked = true;
			this.UpdateRunDisplayInfo();
			this.m_MainPreviewer.Refresh();
		}

		private void cmbTopLevel_SelectedIndexChanged(object sender, EventArgs e)
		{
			int selectedIndex = this.cmbTopLevel.SelectedIndex;
			int selectedIndex2 = this.cmbBottomLevel.SelectedIndex;
			this.m_TopLevel = this.m_listAllLevels.ElementAt(selectedIndex);
			this.hyTbTopOffset.Text = "0.00";
			if (-1 == selectedIndex2)
			{
				return;
			}
			if (selectedIndex == selectedIndex2)
			{
				if (this.m_listAllLevels.Count - 1 == selectedIndex)
				{
					this.m_dLevelValue = Common.FeetToMM(this.m_TopLevel.Elevation - this.m_listAllLevels.ElementAt(selectedIndex - 1).Elevation);
				}
				else
				{
					this.m_dLevelValue = Common.FeetToMM(this.m_listAllLevels.ElementAt(selectedIndex2 + 1).Elevation - this.m_BottomLevel.Elevation);
				}
				this.m_dStairsHeight = this.m_dLevelValue;
				this.TopOffset = this.m_dLevelValue;
				this.m_dLevelValue = 0.0;
			}
			else
			{
				this.m_dStairsHeight = 0.0;
				this.m_dLevelValue = Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
			}
			this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void cmbBottomLevel_SelectedIndexChanged(object sender, EventArgs e)
		{
			int selectedIndex = this.cmbTopLevel.SelectedIndex;
			int selectedIndex2 = this.cmbBottomLevel.SelectedIndex;
			this.m_BottomLevel = this.m_listAllLevels.ElementAt(selectedIndex2);
			this.hyTbBottomOffset.Text = "0.00";
			this.m_dBottomElevation = Common.FeetToMM(this.m_BottomLevel.Elevation);
			if (selectedIndex == selectedIndex2)
			{
				if (this.m_listAllLevels.Count - 1 == selectedIndex)
				{
					this.m_dLevelValue = Common.FeetToMM(this.m_TopLevel.Elevation - this.m_listAllLevels.ElementAt(selectedIndex - 1).Elevation);
				}
				else
				{
					this.m_dLevelValue = Common.FeetToMM(this.m_listAllLevels.ElementAt(selectedIndex2 + 1).Elevation - this.m_BottomLevel.Elevation);
				}
				this.m_dStairsHeight = this.m_dLevelValue;
				this.TopOffset = this.m_dLevelValue;
				this.m_dLevelValue = 0.0;
			}
			else
			{
				this.m_dStairsHeight = 0.0;
				this.m_dLevelValue = Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
			}
			this.ParametersCalculate(RectangleAngleStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		public const double _epsDouble = 1E-09;

		private ExternalCommandData m_Revit;

		private Previewer m_MainPreviewer;

		private RectangleAngleStairsKit m_StairsDrawingKit;

		private ComponentTypeManager m_ComponentTypeManager;

		private List<Level> m_listAllLevels;

		private RectangleAngleStairsForm.MeasureType m_MeasureType;

		private XYZ m_BasePoint;

		private int m_BasePointIndex;

		private int m_nRunCountIndex;

		private bool m_Calculating;

		private bool m_bClockwiseUp = true;

		private double m_dBottomElevation;

		private double m_dLevelValue;

		private Level m_TopLevel;

		private Level m_BottomLevel;

		private List<double> m_listStairsData;

		private double m_dStairsHeight;

		private int m_nOneRunMax;

		private int m_nTwoRunMax;

		private double m_dMinLandWidth = 150.0;

		private int m_nOneCmpTreandCount = 3;

		private int m_nTwoCmpTreandCount = 3;

		private int m_nThreeCmpTreandCount = 3;

		private int m_nFourCmpTreandCount = 3;

		public enum MeasureType
		{
			MT_None,
			MT_StairsLength,
			MT_StairsWidth,
			MT_OneRunWidth,
			MT_TwoRunWidth,
			MT_ThreeRunWidth,
			MT_FourRunWidth,
			MT_Angle
		}

		public enum ValveChangeType
		{
			VCT_None,
			VCT_AddOne,
			VCT_SubtractOne,
			VCT_ValveChanged
		}

		private enum ParametersChangeType
		{
			PCT_StairsLength,
			PCT_StairsWidth,
			PCT_TreadHeight,
			PCT_TreadDepth,
			PCT_OneRunTreadCountAdd,
			PCT_OneRunTreadCountSub,
			PCT_TwoRunTreadCountAdd,
			PCT_TwoRunTreadCountSub,
			PCT_ThreeRunTreadCountAdd,
			PCT_ThreeRunTreadCountSub,
			PCT_FourRunTreadCountAdd,
			PCT_FourRunTreadCountSub
		}
	}
}
